﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace PLCSimulator
{
    public class Symbol
    {
        public static int PinRadius = 6;
        public static int GridSize = PinRadius * 6;
        public static T Skin<T>(string skinPath)
        {
            return (T)Application.LoadComponent(new Uri(skinPath, UriKind.Relative));
        }

        public static FrameworkElement Skin(string skinPath)
        {
            return Skin<FrameworkElement>(skinPath);
        }
        public static Point GridPoint(Point screenPoint)
        {
            var gridPoint = new Point(
                (int)Math.Round(screenPoint.X / Symbol.GridSize),
                (int)Math.Round(screenPoint.Y / Symbol.GridSize)
            );
            return gridPoint;
        }

        public static Point ScreenPoint(Point screenPoint)
        {
            var gridPoint = GridPoint(screenPoint);
            var screenP = new Point(gridPoint.X * Symbol.GridSize, gridPoint.Y * Symbol.GridSize);
            return screenP;
        }
    }
}
